import Request from '@/api/request.js'

class CommonApi{
	
	constructor(path) {
	    this.path = path;
	}
	
	// 查询列表
	list(query) {
		return Request.request({
			url: this.path + '/list',
			method: 'GET',
			data: query
		});
	}
	
	// 查询详细
	getInfo(id) {
		return Request.request({
			url: this.path + '/' + id,
			method: 'GET'
		});
	}
	
	// 根据IDS查询
	listByIds(ids) {
		return Request.request({
			url: this.path + '/listByIds',
			method: 'GET',
			data: ids
		});
	}
	
	// 查询数量
	count(query) {
		return Request.request({
			url: this.path + '/count',
			method: 'GET',
			data: query
		});
	}
	
	// 保存
	save(data) {
	  return Request.request({
	    url: this.path,
	    method: 'POST',
	    data: data
	  })
	}
	
	// 修改
	update(data) {
	  return Request.request({
	    url: this.path,
	    method: 'PUT',
	    data: data
	  })
	}
	
	// 删除
	remove(id) {
	  return Request.request({
	    url: this.path + '/' + id,
	    method: 'DELETE'
	  })
	}
	
	// 条件删除
	removes(data) {
	    return Request.request({
	        url: this.path + '/remove',
	        method: 'delete',
	        data: data
	    })
	}
	
	// 请求
	static request(option){
		return Request.request(option);
	}
}

export default CommonApi;

